using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace NodeCanvas.BehaviourTrees
{
	[AddComponentMenu("")]
	public abstract class BTNodeBase : Node, IAutoSortable
	{
		public override Type outConnectionType
		{
			get
			{
				return typeof(BTConnection);
			}
		}

		public override int maxInConnections
		{
			get
			{
				return 1;
			}
		}

		public override int maxOutConnections
		{
			get
			{
				return 0;
			}
		}

		public List<BTNodeBase> GetAllChildNodesRecursively(bool includeThis)
		{
			List<BTNodeBase> list = new List<BTNodeBase>();
			if (includeThis)
			{
				list.Add(this);
			}
			foreach (BTNodeBase item in base.outConnections.Select((Connection c) => c.targetNode))
			{
				list.AddRange(item.GetAllChildNodesRecursively(true));
			}
			return list;
		}

		public Dictionary<BTNodeBase, int> GetAllChildNodesWithDepthRecursively(bool includeThis, int startIndex)
		{
			Dictionary<BTNodeBase, int> dictionary = new Dictionary<BTNodeBase, int>();
			if (includeThis)
			{
				dictionary[this] = startIndex;
			}
			foreach (BTNodeBase item in base.outConnections.Select((Connection c) => c.targetNode))
			{
				foreach (KeyValuePair<BTNodeBase, int> item2 in item.GetAllChildNodesWithDepthRecursively(true, startIndex + 1))
				{
					dictionary[item2.Key] = item2.Value;
				}
			}
			return dictionary;
		}
	}
}
